package com.atguigu.UDP_b;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

public class Server {
    public static void main(String[] args) throws IOException {

        System.out.println("=====服务器启动成功=====");

        DatagramSocket socket = new DatagramSocket(6666);

        byte[] bytes = new byte[1024*64];
        DatagramPacket packet = new DatagramPacket(bytes,bytes.length);
        socket.receive(packet);

        byte[] data = packet.getData();
        int length = packet.getLength();
        InetAddress ip = packet.getAddress();
        int port = packet.getPort();

        String rs = new String(data,0,length);
        System.out.println(rs);

        socket.close();
    }
}
